Inject BCS_API_KEY secret as step-level env var in bilbao-test workflow#316
Draft
Inject BCS_API_KEY secret as step-level env var in bilbao-test workflow#316
Conversation
Co-authored-by: briantoby <9433704+briantoby@users.noreply.github.com> Agent-Logs-Url: https://github.com/AdvancedPhotonSource/GSAS-II/sessions/cfde2486-9f48-45be-8284-acf7eb7c13eb
Copilot
AI
changed the title
[WIP] Update GitHub Actions workflow to add BCS_API_KEY
Inject BCS_API_KEY secret as step-level env var in bilbao-test workflow
Mar 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Bilbao self-test step needs access to
BCS_API_KEYat runtime, but the secret was never wired into the workflow.Change
Added
env: BCS_API_KEY: ${{ secrets.BCS_API_KEY }}scoped to only therun Bilbao self-teststep (not job-level, minimizing exposure):Creating the secret
In
AdvancedPhotonSource/GSAS-II: Settings → Secrets and variables → Actions → New repository secretBCS_API_KEYGitHub automatically masks
secrets.*values in logs — do notechothe variable explicitly.Original prompt
Create a pull request in
AdvancedPhotonSource/GSAS-IIthat updates the GitHub Actions workflow.github/workflows/bilbao-test.ymlto inject the secretBCS_API_KEYas an environment variable at step-level (only for therun Bilbao self-teststep).Context:
64e587b44a3579cd59895ff8ca6004ce973f6819Required change:
run Bilbao self-test, add:env:mappingBCS_API_KEY: ${{ secrets.BCS_API_KEY }}Add instructions in PR description (or as a comment in the PR body) explaining how to create the secret:
AdvancedPhotonSource/GSAS-II→ Settings → Secrets and variables → Actions → New repository secretBCS_API_KEYValidation:
Deliverable:
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: How do I set an environment variable for a Github workflow process that keeps the variable setting as a secret
Assistant: You don’t “set an environment variable as a secret” in GitHub Actions. Instead, you store the value as a GitHub Secret, then inject it into the workflow as an environment variable at runtime. GitHub will automatically mask secrets in logs (and you can also mask additional values). (docs.github.com)
1) Create the secret (recommended place to store it)
Create a secret in one of these scopes:
environment:with protection rules)GitHub docs walk through creating repo/environment/org secrets. (docs.github.com)
2) Use the secret as an environment variable in your workflow
Step-level env (most common)
This pattern (mapping
${{ secrets.NAME }}intoenv:) is the standard approach. (docs.github.com)Job-level env (available to all steps in the job)
3) If you need it to persist across steps (without repeating
env:)Write to
$GITHUB_ENV(this makes it available to later steps in the same job):Be careful not to print it.
4) Keep it from leaking in logs
secrets.*automatically in logs. (docs.github.com)GitHub specifically recommends masking sensitive values that aren’t already GitHub secrets. (docs.github.com)
Important notes
echothe secret (even though masking helps, it’s still risky).GITHUB_TOKEN). (docs.github.com)If you paste your workflow snippet (just the relevant job/steps), I can show the exact safest way to wire your secret into the command you’re running (bash/pwsh/cmd differences matter).
User: The workflow that I plan to modify is @AdvancedPhotonSource/GSAS-II/files/.github/workflows/bilbao-test.yml and the environment variable needed to be set is BCS_API_KEY
Assistant: To keep
BCS_API_KEYsecret in that workflow, you should store it as a GitHub Actions secret and then map it into an environment variable inside the job (or just the one step that needs it).1) Create the secret
I...
This pull request was created from Copilot chat.
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.